<!-- 病害派单页面 -->
<template>
	<view class="">
		<dispatch  titleName="病害审核" compoType="disease_review" :treeData="copyData" @searchChange="searchChange"
			@determine="determine"></dispatch>
	</view>
</template>


<script>
	import dispatch from '../common/dispatch.vue'
	import searchCom from "@/components/searchCom.vue"
	import mixins from '@/utils/mixins.js'
	import {
		getPlanLineSectionSiteStateTreeByLike, //树形列表
		inspectLogUpdateState, //更改状态
	} from '@/api/engineeringMaintenance/engineeringMaintenance.js'
	import {
		doSave,
		doGet,
		doCache
	} from '@/utils/offline/index.js'
	export default {
		name: 'diseaseReview',
		mixins: [mixins],
		components: {
			searchCom,
			dispatch
		},

		data() {
			return {
				keyword: undefined,
				treeData: [],
				copyData: []
			}
		},
		onShow() {
			this.$nextTick(() => {
				this.getTreeListData()
			})
		},
		methods: {
			// 获取树形数据
			getTreeListData() {
				getPlanLineSectionSiteStateTreeByLike({
						projectId: uni.getStorageSync('isOwner'),
						projectStates:["zj","zt"],
						type: 'disease_review',
					})
					.then(res => {
						console.log(res)
						if (res.status === 1 && res.success) {
							this.treeData = res.result
							this.copyData = this.filterData(res.result)
							// this.print(this.copyData)
							console.log(this.copyData, '审核数据');
						}
					})
			},
			// print(list){
			// 	if(!list) return
			// 	if(!Array.isArray(list)){
			// 		console.log(list.name)
			// 		return
			// 	}
			// 	if(list.length===0) {
			// 		console.log(list.name)
			// 		return
			// 	}
			// 	list.forEach(it=>this.print(it.list))
			// },
			/**
			 * 输入框值变化的时候
			 * @param {String} val
			 */
			searchChange(val) {
				// this.keyword = val
				if (!val) {
					this.copyData = this.filterData(this.treeData)
				}
			},
			determine(ev) {
				console.log(ev)
				if(!ev) {
					this.copyData = this.filterData(this.treeData)
				}else {
					this.copyData = this.mapTree(ev, this.treeData)					
				}
				
			},
		}
	}
</script>

<style lang="scss" scoped>
</style>
